'use strict';

module.exports = function createUpdatedCollection(collectionA, objectB) {
  let arr1 = [];
  let arr2 = objectB.value;
  let obj = {};
  for(let item of collectionA){
    if(!obj[item]){
      obj[item] = {};
      obj[item].key = item;
      obj[item].count = 1;
    }
    else{
      obj[item].count++;
    }
  }
  
  for(let item in obj){
    arr1.push(obj[item]);
  }
  for(let item of arr1){
    for(let n of arr2){
      if(item.key == n){
        item.count=item.count-parseInt(item.count/3);
      }
    }
  }
  return arr1;
}
